package org.wkg.lesson02;

public class Demo_206 {

    static boolean isQuit = false;

    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(() -> {
            while (!isQuit) {
                System.out.println("hello thread...");
                try {
                    Thread.sleep(100);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            System.out.println("线程退出");
        });
        System.out.println(thread.getName() + " :isAlive: " + thread.isAlive());
        thread.start();
        System.out.println(thread.getName() + " :isAlive: " + thread.isAlive());
        Thread.sleep(1000);
        isQuit = true;
        Thread.sleep(100);
        System.out.println(thread.getName() + " :isAlive: " + thread.isAlive());
    }
}
